<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>3-闭包打印li的内容</title>
</head>
<body>
    <ul>
        <li type="1">百度</li>
        <li type="2">新浪</li>
        <li type="3">阿里</li>
    </ul>
    <script>
        var lis = document.querySelector('ul').querySelectorAll('li');//NodeList
        //循环
        for(var i=0;i<lis.length;i++){
            //闭包
            (function(i){
                setTimeout(function(){
                    console.log(lis[i].innerHTML);
                },3000);
            }(i));
        }

    </script>

</body>
</html>